#include "MyIncludes.h"
#include "Worker.h"


Worker::Worker()
{
	//name = -1;
	//seniority = -1;
}
Worker::Worker( const Worker & worker )
{
	this->name = worker.name; // ??? IMPLEMENT = OPERATOR of stringKey????
	this->rank = worker.rank;
	this->seniority = worker.seniority;
}
Worker::Worker( const StringKey & name , const unsigned int & seniority  , const unsigned int & rank )
{
	this->name = name;
	this->seniority = seniority;
	this->rank = rank;
}
Worker::~Worker()//Why should I have a distructor?
{
	
}

StringKey * Worker::getKey () 
{
	return &name;
}
Worker * Worker::read ()
{
	Worker * res = new Worker;
	res->getKey()->Read();
	if ( res->getKey()->getKey().empty() ) //nothing was read into the file
	{
		cout << "Error on loading StringKey" ;
	}
	else // successfully read into file
	{
		cin >> res->rank;
		cin >> res->seniority;
	}
	return res;
}
unsigned int Worker::getRank()
{
	return rank;
}
unsigned int Worker::getSeniority()
{
	return seniority;
}
void Worker::setRank ( unsigned int rank )
{
	this->rank = rank;
}
ostream & operator << ( ostream & out , const Worker & worker )
{
	out << worker.name.getKey() << " " << worker.rank << " " << worker.seniority << "\n" ;
	return out;
}
istream & operator >> ( istream & in , Worker & worker )
{
	in >> worker.name  >> worker.rank  >> worker.seniority ;
	return in;
}
